package pikes.peak;

import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;

import org.junit.Assert;
import org.junit.Test;

import pikes.peak.test.PikesPeakComponentTestCase;
import pikes.peak.test.PikesPeakTestRequest;
import pikes.uri.RelativeURI;
import pikes.uri.URI;

public class InternalURITestCase extends PikesPeakComponentTestCase {

	protected PikesPeakTestRequest createPikesPeakTestRequest() {
		return new PikesPeakTestRequest(messageSource, themeMessageSource, localeResolver, themeResolver,
				"/countries/main/home");
	}

	@Test
	public void simpleInternalURI() throws Exception {
		InternalURI uri = new InternalURI("/home");

		URI uriText = uri.getValue(new HashMap(), pikesPeakRequest.getRequestContext());
		Assert.assertEquals(new RelativeURI(new RelativeURI("countries"), "home"), uriText);
	}

	@Test
	public void simpleInternalURI1() throws Exception {
		InternalURI uri = new InternalURI("home");

		URI uriText = uri.getValue(new HashMap(), pikesPeakRequest.getRequestContext());
		Assert.assertEquals(new RelativeURI(new RelativeURI("countries"), "home"), uriText);
	}

	@Test
	public void simpleInternalURIWithParameters() throws Exception {
		Map<CharSequence, CharSequence> parameters1 = new LinkedHashMap<CharSequence, CharSequence>();
		parameters1.put("theme", "spring");
		InternalURI uri = new InternalURI("/home", parameters1);

		Map<CharSequence, CharSequence> parameters = new LinkedHashMap<CharSequence, CharSequence>();
		parameters.put("theme", "spring");

		URI uriText = uri.getValue(new HashMap(), pikesPeakRequest.getRequestContext());
		Assert.assertEquals(new RelativeURI(new RelativeURI("countries"), "home", parameters), uriText);
	}

}
